<template>
    <div>
        <el-row>
            <el-col :span="24">
                <div class="grid-content bg-purple">
                    <el-form :inline="true" label-width="100" :rules="rules" ref="formInline" :model="formInline"  class="demo-form-inline">
                         <el-form-item label="架次" prop="planeNo">
                            <el-input class="input-width" v-model="formInline.planeNo" size="mini" placeholder="必填查询参数"></el-input>
                        </el-form-item>
                        <el-form-item label="AO编号">
                            <el-input size="mini" v-model="formInline.aoCode" placeholder="AO编号"></el-input>
                        </el-form-item>
                        <el-form-item label="图号">
                            <el-input size="mini" v-model="formInline.itemCode" placeholder="图号"></el-input>
                        </el-form-item>
                        <el-form-item label="分拣状态">
                            <el-select size="mini" v-model="formInline.isSort" placeholder="分拣状态">
                                <el-option label="所有" value=""></el-option>
                                <el-option label="未分拣" value="N"></el-option>
                                <el-option label="已分拣" value="Y"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="是否装车">
                            <el-select size="mini" v-model="formInline.status" placeholder="是否装车">
                                <el-option label="全部" value=""></el-option>
                                <el-option label="已装车" value="I"></el-option>
                                <el-option label="未装车" value="W"></el-option>
                                <el-option label="已配送" value="S"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item>
                            <el-button size="mini" type="primary" @click="deliveryQuery">查询</el-button>
                            <el-button size="mini" type="primary" @click="sendMaterial">配送</el-button>
                        </el-form-item>
                    </el-form>
                </div>
            </el-col>
        </el-row>
        <el-row>
            <el-col :span="24">
                <div class="grid-content bg-purple">
                    <slot>物料查询列表</slot>
                    <el-table :data="aoinfo.tableData" highlight-current-row border 
                            @current-change="currentDataChange" @selection-change="handleSelectionChange" 
                            height="600" stripe style="width: 100%">
                        <el-table-column type="selection" width="50"></el-table-column>
                        <el-table-column type="index" width="50"></el-table-column>
                        <el-table-column prop="aoCode"  label="AO号" width="200" show-overflow-tooltip></el-table-column>
                        <el-table-column prop="itemCode"  label="图号" width="200" show-overflow-tooltip></el-table-column>
                        <el-table-column prop="qualityCode"  label="质量编号" width="100" show-overflow-tooltip></el-table-column>
                        <el-table-column prop="repartAss"  label="装配图号" width="200" show-overflow-tooltip></el-table-column>
                        <el-table-column prop="mesCheckQualiticationId"  label="合格证号" width="200" show-overflow-tooltip></el-table-column>
                        <el-table-column prop="planeNo"  label="架次" width="100" show-overflow-tooltip></el-table-column>
                        <el-table-column prop="toolCode"  label="托盘号" width="200" show-overflow-tooltip></el-table-column>
                        <el-table-column prop="carCode"  label="小车编码" width="150" show-overflow-tooltip></el-table-column>
                        <el-table-column prop="packageCount"  label="分拣数量" width="100" show-overflow-tooltip></el-table-column>
                        <el-table-column prop="isSort"  label="分拣状态" width="100" show-overflow-tooltip></el-table-column>
                        <el-table-column prop="status"  label="装车状态" width="150" show-overflow-tooltip></el-table-column>
                        <el-table-column prop="msAoMatchInfoId"  label="配套表主键" width="150" show-overflow-tooltip></el-table-column>
                        <el-table-column prop="msTaskAoId"  label="AO表主键" width="150" show-overflow-tooltip></el-table-column>
                    </el-table>
                    <el-pagination @size-change="handleSizeChange"  @current-change="handleCurrentChange" :current-page="aoinfo.page.currentPage"
                        :page-sizes="[20, 50, 100, 500]" :page-size="aoinfo.page.pageSize" layout="total, sizes, prev, pager, next" :total="aoinfo.page.total">
                    </el-pagination>
                </div>
            </el-col>
        </el-row>
    </div>
</template>
<script>
import request from '@/utils/request.js';
export default {
    name:"",
    data(){
        return {
            //查询条件
            formInline:{
                aoCode:"",
                itemCode:"",
                planeNo:"",
                isSort:"",
                status:""
            },
            rules:{
                planeNo:[{ required: true, message: '请输入架次', trigger: 'blur' }]
            },
            //物料查询信息
            aoinfo:{
                tableData:[],
                page:{
                    currentPage:1,
                    total:0,
                    pageSize:20
                },
                selectData:[]
            },
            selectData2:[]
        }
    },
    methods:{
        deliveryQuery(){//查询物料信息清单
            this.$refs["formInline"].validate((valid) => {
                if (valid) {
                    request.post("/MsDeliveryPackageInfoRest/deliveryMaterial",{page:this.aoinfo.page,queryParam:this.formInline}).then((res)=>{
                        this.aoinfo.tableData = res.data.list;
                        this.aoinfo.page.total = res.data.total;
                    });
                } else {
                    console.log('error submit!!');
                    return false;
                }
            });
        },
        sendMaterial(){
            if(this.selectData2.size==0){
                this.$Alert({title:"错误",type:"error",message:"请先选择至少一条记录！"});
                return ;
            }
            request.post("/MsDeliveryPackageInfoRest/materialSend",this.selectData2).then((res)=>{
                if(res.data.retCode=="200"){
                    this.$Alert({title:"成功",type:"success",message:res.data.message});
                }else{
                    this.$Alert({title:"错误",type:"error",message:res.data.message});
                }
                this.$options.methods.deliveryQuery.bind(this)();
            });
        },
        currentDataChange(val){
            this.aoinfo.selectData = val;
        },
        handleSelectionChange(val){
            this.selectData2 = val;
        },
        handleSizeChange(val){
            this.aoinfo.page.pageSize = val;
        },
        handleCurrentChange(val){
            this.aoinfo.page.currentPage = val;
        }
    }
}
</script>